<?php
// +----------------------------------------------------------------------
// | PHP [ JUST YOU ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2017 http://www.jyphp.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: FlyingPig <flyingpigfp@163.com>
// +----------------------------------------------------------------------

namespace App\Http\Controllers;


use App\Common\HttpClient;
use App\Common\Tool;
use App\Exceptions\ApiException;
use App\Logic\MiGuLogic;
use Flc\Dysms\Client;
use Flc\Dysms\Request\SendSms;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Redis;
use Illuminate\Support\Facades\Route;

class Demo extends Base
{

    public function index(Request $request)
    {
        dump( Redis::eval(file_get_contents(base_path() . '/redisscript/get_room.lua'), 2, env('REDIS_ROOM_KEY'), 276095) );
        dump( Redis::hGet(env('REDIS_ROOM_KEY'),276095));
        return;

//        $code = system('sudo /Users/flyingpig/Downloads/test.sh',$code);
       exec("/data/test.sh",$output,$code);
        dump($code);
        dump($output);
//        dump(count($data));
//        dump('Q_' . env('REDIS_ROOM_KEY'));
//        dump( $pwd = Redis::spop('Q_' . env('REDIS_ROOM_KEY')) );
//        $pwd = Tool::redisRand();
//        dump($pwd);
//        dump( Tool::setRedisRoomKey('8888888',$pwd) );
//        dump(Tool::getRedisRoomId($pwd));

//        Redis::eval(file_get_contents(base_path().'/redisscript/return_room.lua'),2,env('REDIS_ROOM_KEY'),711276);
//        dump( Tool::redisInit() );
//        dump( Tool::redisRand(1234) );
//        dump( Redis::eval(file_get_contents(base_path().'/redisscript/create_room.lua'),2,env('REDIS_ROOM_KEY'),123) );
//            dump(base_path());
//        $path = app_path() . '/Common/test.lua';
//        echo file_get_contents($path);
//        $sha1 = file_get_contents($path);
//        Redis::eval($sha1, 2, 'test_password', 1234);
//        dump(json_encode([
//            'board_choose' => 4,
//            'club_id' => 10000,
//            'player_num' => 4,
//            'use_cards' => 3,
//        ]));
//        $migu_info = MiGuLogic::instance()->get_migu_user_info(1550299);
//        dump($migu_info);
////
//        $data              = [
//            'gameId' => 111,
//            'timestamp' => (string)Tool::msectime(),
//            'userId' => 1294007,
//            'operateTypeSub' => 2,
//            'localPropDst' => 100004,
//            'localPropNum' => 18,
//            'localScaleNum' => 1,
//            'thirdGameName' => '贵州麻将',
//            'thirdPropId' => 10001,
//            'thirdPropName' => 10 . '钻石',
//            'thirdPropNum' => 10,
//            'thirdScaleNum' => 10
//        ];
//        $data['signature'] = Tool::miGuSignature($data);
//        $url               = MiGuLogic::$base_url.'/exchange/diamond';
//        $response          = (new HttpClient())->MiGuPost($url, json_encode($data));
//        $response          = json_decode($response, true);
//        dump($response);
//
//        $migu_info = MiGuLogic::instance()->get_migu_user_info(1294007);
//        dump($migu_info);
    }
}